#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>

const int N = 200 + 7;
const int M = 2000 + 7;

int n, m;
double o[N], r;
double p[M][N], d[M], rd[M];
double dis[M][M];

int main() {
	
    double x, y, z, s, sp, h, alpha, beta, theta;
	
    scanf("%d%d%lf", &n, &m, &r);
    for(int i = 1; i <= n; ++i) 
	scanf("%lf", &o[i]);
    for(int i = 1; i <= m; ++i) 
	for(int j = 1; j <= n; ++j)
	    scanf("%lf", &p[i][j]);
		
    for(int i = 1; i <= m; ++i) {
		x = 0;
		for(int j = 1; j <= n; ++j)
		    x += (p[i][j] - o[j]) * (p[i][j] - o[j]);
		d[i] = sqrt(x);	//点到黑洞中心的距离
		rd[i] = sqrt(d[i] * d[i] - r * r);
    }
	
    for(int i = 1; i <= m; ++i)
		for(int j = i + 1; j <= m; ++j) {
		    x = 0;
		    for(int k = 1; k <= n; ++k)
				x += (p[i][k] - p[j][k]) * (p[i][k] - p[j][k]);
		    x = sqrt(x);	//两点之间的距离
		    sp = (x + d[i] + d[j]) / 2;
		    s = sqrt(sp * (sp - x) * (sp - d[i]) * (sp - d[j]));
		    h = 2 * s / x;
		    if(h >= r || x * x + d[i] * d[i] <= d[j] * d[j] || x * x + d[j] * d[j] <= d[i] * d[i]) {
				dis[i][j] = dis[j][i] = x; 
				continue;
		    }
		    theta = acos((d[i] * d[i] + d[j] * d[j] - x * x) / (2 * d[i] * d[j]));
		    alpha = acos(r / d[i]);
		    beta = acos(r / d[j]);
		    //printf("%lf %lf %lf\n", theta, alpha, beta);
		    dis[i][j] = dis[j][i] = rd[i] + rd[j] + r * (theta - alpha - beta);
	}
	
    double ans;
    for(int i = 1; i <= m; ++i) {
		ans = 0;
		for(int j = 1; j <= m; ++j)
		    ans += dis[i][j];
		printf("%.20lf\n", ans);
    }
	
    return 0;
	
}